package com.yf1706.service;

import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yf1706.bean.CheckHolidayKind;
import com.yf1706.dao.jpa.IHolidayKindJDAO;
import com.yf1706.dao.mybatis.IHolidayKindMDAO;

@Service
@Transactional(rollbackFor=Exception.class)
public class HolidayKindService {
	@Autowired
	private IHolidayKindJDAO hkJDao;
	@Autowired
	private IHolidayKindMDAO hkMDao;
	/**
	 * 查询所有的假种信息
	 * @return
	 */
	public List<CheckHolidayKind> getHolidayKindList(){
		return hkMDao.queryHolidayKind();
	}
	public Optional<CheckHolidayKind> getHolidayKind(int id){
		return hkJDao.findById(id);
	}
	//模糊查询假种信息
	public List<CheckHolidayKind> getSerchHolidayKindList(String holidayname){
		return hkMDao.querySerchHolidayKind(holidayname);
	}
	
	//存储新增的假种
	public void addHoliday(String holidayName,String whetherSalary,String remark,String person,String statutory,String systemUse,String maker) {
	CheckHolidayKind   chk=new CheckHolidayKind();
	chk.setHolidayName(holidayName);
	chk.setWhetherSalary(whetherSalary);
	chk.setRemark(remark);
	chk.setPersonageHoliday(person);
	chk.setStatutoryHoliday(statutory);
	chk.setSystemUse(systemUse);
	chk.setMaker(maker);
	chk.setMakeTime(new Date());
	chk.setState("是");
	hkJDao.save(chk);
	}
	//删除指定的假种信息
	public void deleteHoliday(int holidayId) {
		hkJDao.deleteById(holidayId);
	}
	//修改指定的假种信息
	public void updateHoliday(CheckHolidayKind holidayKind) {
		holidayKind.setUpdateTime(new Date());
		holidayKind.setState("是");
		hkJDao.save(holidayKind);
	}
}
